package cn.humaohua.study.yanmo_design_pattern.ch02;

public class ApiFactory {
    private ApiFactory() {
    }

    public static Api createApi() {
        return new Api_A_Impl();
    }

    /**
     * 可以更灵活一点，根据参数或者配置信息，获取指定类型对象
     */
    public static Api createApi(int type) {
        if (type == 1) {
            return new Api_A_Impl();
        } else if (type == 2) {
            return new Api_B_Impl();
        }
        return null;
    }
}
